import request from '../utils/request';

const baseURL = 'http://localhost:8080/api';
export const fetchData = () => {
    return request({
        url: './mock/table.json',
        method: 'get'
    });
};

export const validateTeacherLogin = (loginData) => {
    return request({
        baseURL: baseURL,
        url: '/teacherLogin',
        method: 'post',
        data: loginData
    });
}
export const validateStudentLogin = (loginData) => {
    return request({
        baseURL: baseURL,
        url: '/studentLogin',
        method: 'post',
        data: loginData
    });
}
export const getAllColleges = () => {
    return request({
        baseURL: baseURL,
        url: '/getAllColleges',
        method: 'get'
    });
}
export const selectTeachClass = (tc_id) => {
    return request({
        baseURL: baseURL,
        url: '/selectTeachClass',
        method: 'post',
        data: tc_id,
        headers: {'Content-Type': 'application/json'}
    });

}
export const updateTeachClass = (tc) => {
    return request({
        baseURL: baseURL,
        url: '/updateTeachClass',
        method: 'post',
        data: tc
    });

}
export const insertTeachClass = (tc) => {
    return request({
        baseURL: baseURL,
        url: '/insertTeachClass',
        method: 'post',
        data: tc
    });

}
export const deleteTeachClass = (tc_id) => {
    return request({
        baseURL: baseURL,
        url: '/deleteTeachClass',
        method: 'post',
        data: tc_id,
        headers: {'Content-Type': 'application/json'}
    });

}
export const insertSession = (session) => {
    return request({
        baseURL: baseURL,
        url: '/insertSession',
        method: 'post',
        data: session
    });

}
export const deleteSession = (session_id) => {
    return request({
        baseURL: baseURL,
        url: '/deleteSession',
        method: 'post',
        data: session_id,
        headers: {'Content-Type': 'application/json'}
    });


}
export const insertCourse = (course) => {
    return request({
        baseURL: baseURL,
        url: '/insertCourse',
        method: 'post',
        data: course
    });

}

export const updateCourse = (course) => {
    return request({
        baseURL: baseURL,
        url: '/updateCourse',
        method: 'post',
        data: course
    });

}
export const deleteCourse = (course_id) => {
    return request({
        baseURL: baseURL,
        url: '/deleteCourse',
        method: 'post',
        data: course_id,
        headers: {'Content-Type': 'application/json'}
    });

}
export const deleteStudentCourse = (cond) => {
    return request({
        baseURL: baseURL,
        url: '/deleteStudentCourse',
        method: 'post',
        data: cond,
        headers: {'Content-Type': 'application/json'}
    });

}

export const updateStudentCourse =(sc)=>{
    return request({
        baseURL: baseURL,
        url: '/updateStudentCourse',
        method: 'post',
        data: sc,
        headers: {'Content-Type': 'application/json'}
    });
}
export const fetchStudentCourse = (page) => {
    return request({
        baseURL: baseURL,
        url: '/getSelectedCourses',
        method: 'post',
        data:page,
    });
}
export const fetchTeachClassPage = (page) => {
    return request({
        baseURL: baseURL,
        url: '/getPageTeachClass',
        method: 'post',
        data:page,
    });
}
export const fetchStudentData = (page,query) => {
    return request({
        baseURL: baseURL,
        url: '/getStudents',
        method: 'post',
        data:{...page,...query}
    });
}

export const fetchTeacherData = (page,query) => {
    return request({
        baseURL: baseURL,
        url: '/getTeachers',
        method: 'post',
        data:{...page,...query}
    });
}
export const fetchCoursePage = (page,query) => {
    return request({
        baseURL: baseURL,
        url: '/getPageCourses',
        method: 'post',
        data:{...page,...query}
    });
}
export const fetchCourseTeachClass = (cid) => {
    return request({
        baseURL: baseURL,
        url: '/getCourseTeachClasses',
        method: 'post',
        data:cid,
        headers: {'Content-Type': 'application/json'}

    });
}
export const fetchSessionByTcId = (tc_id) => {
    return request({
        baseURL: baseURL,
        url: '/getSessionByTcId',
        method: 'get',
        params:{tc_id}
    });
}
export const deleteStudentData = (sid) => {
    return request({
        baseURL: baseURL,
        url: '/deleteStudent',
        method: 'post',
        data:sid,
        headers: {
            'Content-Type': 'application/json'
        }

    });
}
export const deleteTeacherData = (tid) => {
    return request({
        baseURL: baseURL,
        url: '/deleteTeacher',
        method: 'post',
        data:tid,
        headers: {
            'Content-Type': 'application/json'
        }

    });
}
export const updateTeacherData = (data) => {
    return request({
        baseURL: baseURL,
        url: '/updateTeacher',
        method: 'post',
        data:data,

    });
}
export const updateStudentData = (data) => {
    return request({
        baseURL: baseURL,
        url: '/updateStudent',
        method: 'post',
        data:data,

    });
}
export const insertStudentData = (data) => {
    return request({
        baseURL: baseURL,
        url: '/insertStudent',
        method: 'post',
        data:data
    });
}
export const insertTeacherData = (data) => {
    return request({
        baseURL: baseURL,
        url: '/insertTeacher',
        method: 'post',
        data:data
    });
}
export const updateStudentPasswd = (passwd) =>{
    return request({
        baseURL: baseURL,
        url: '/updateStudentPasswd',
        method: 'post',
        data:passwd,
        headers: {
            'Content-Type': 'application/json'
        }
    });
}
export const updateTeacherPasswd = (passwd) =>{
    return request({
        baseURL: baseURL,
        url: '/updateTeacherPasswd',
        method: 'post',
        data:passwd,
        headers: {
            'Content-Type': 'application/json'
        }
    });
}
export const postLogout = () =>{
    return request({
        baseURL: baseURL,
        url: '/logout',
        method: 'post',
    });
}
export const fetchUserData = () => {
    return request({
        url: './mock/user.json',
        method: 'get'
    });
};

export const fetchRoleData = () => {
    return request({
        url: './mock/role.json',
        method: 'get'
    });
};

